<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Create a SVMModel based on training data</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="svm.setoptions.html">« SVM::setOptions</a></li>
      <li style="float: right;"><a href="class.svmmodel.html">SVMModel »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.svm.html">SVM</a></li>
    <li>Create a SVMModel based on training data</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="svm.train" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SVM::train</h1>
  <p class="verinfo">(PECL svm &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">SVM::train</span> &mdash; <span class="dc-title">Create a SVMModel based on training data</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-svm.train-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>svm::train</strong></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$problem</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter">$weights</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="class.svmmodel.html" class="type SVMModel">SVMModel</a></span></div>

  <p class="para rdfs-comment">
   Train a support vector machine based on the supplied training data. 
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-svm.train-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">problem</code></dt>

     <dd>

      <p class="para">
       The problem can be provided in three different ways. 
       An array, where the data should start with the class label 
       (usually 1 or -1) then followed by a sparse data set of 
       dimension =&gt; data pairs. 
       A URL to a file containing a SVM Light formatted problem, with the 
       each line being a new training example, the start of each line 
       containing the class (1, -1) then a series of tab separated data 
       values shows as key:value. 
       A opened stream pointing to a data source formatted as in the file above. 
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">weights</code></dt>

     <dd>

      <p class="para">
       Weights are an optional set of weighting parameters for the different 
       classes, to help account for unbalanced training sets. For example, 
       if the classes were 1 and -1, and -1 had significantly more example 
       than one, the weight for -1 could be 0.5. Weights should be in the range 0-1.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-svm.train-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an SVMModel that can be used to classify previously unseen data.
   Throws SVMException on error
  </p>
 </div>


</div></div></div></body></html>